<?php
include_once "Activity_DAO.php";
include_once "Activitytype.php";

class Activity extends Activity_DAO{
	/**
	 * Extension of the base data class.
	 * Return the label of the activity type
	 * @return string a Label
	 */
	public function getActivityTypeLabel(){
		return $this->getActivityType_id_Ref()->getLabel();
	}
	
	/**
	 * Extension of the base data class.
	 * Return "archived" if the activity is archived.
	 * @return string
	 */
	public function getIsArchivedStatus(){
		if($this->getIsArchived()){
			return "archived";
		}
		return "active";
	}
	
	/**
	 * Return the name of the responsible user
	 * @return string
	 */
	public function getResponsibleUserFullName(){
		return $this->getResponsibleUser_id_Ref()->getFullName();
	}
	
	/**
	 * Get associated report items
	 * @return array an array or Items
	 */
	public function getAllReportItems(){
		return Item::getFromCustomCriteria(
			"WHERE Activity_id=:activityId and ItemType_id=:itemTypeId and ItemStatus_id=:itemStatusId ORDER BY created DESC",
			array(
				"activityId" => $this->getId(),
				"itemTypeId" =>Item::REPORTITEM_TYPE,
				"itemStatusId" =>Item::REPORTITEM_STATUS_CREATED));
	}
}
?>